-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: Add hierarchical .roo configuration resolution for mono-repos #8826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Implement hierarchical directory walking in getRooDirectoriesForCwd - Update CustomModesManager to support hierarchical .roomodes files - Add comprehensive tests for hierarchical resolution - Maintain backward compatibility with legacy mode (non-hierarchical) Fixes #8825
Review SummaryI've reviewed this PR and identified 2 issues that should be addressed:
|
| // Create a generic pattern to watch all .roomodes files in the workspace tree | ||
| const roomodesPattern = new vscode.RelativePattern(workspaceFolders[0], "**/.roomodes") | ||
| const roomodesWatcher = vscode.workspace.createFileSystemWatcher(roomodesPattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file watcher pattern **/.roomodes only watches files within the workspace directory, but getHierarchicalRoomodes() walks up to parent directories outside the workspace. This means changes to .roomodes files in parent directories won't trigger updates, requiring users to restart VSCode. For example, if the workspace is /home/user/mono-repo/packages/frontend and there's a .roomodes at /home/user/mono-repo/.roomodes, changes to the parent file won't be detected since it's outside the workspace tree being watched.
|
@roomote this pr seems not to take into account mcp settings , they can be located at any level too, same location that the .roo folder or the .roomodes can be placed |
|
Thanks for the callout, @colombod. You are correct: the current PR adds hierarchical resolution for .roo and .roomodes but does not include MCP configuration discovery. I will extend the hierarchical walker to detect MCP settings at each directory level (same locations as .roo and .roomodes), define a merge strategy where specific settings override general ones, and add tests for common mono repo layouts. I will push an update soon. |
…merge; use safeWriteJson for atomic writes; add tests
|
Added hierarchical MCP settings resolution: .roo/mcp.json discovered at any directory level and merged parent→child (most specific wins). Tool metadata respects merged alwaysAllow/disabledTools. Writes now use safeWriteJson for atomic updates. Impl: src/services/mcp/McpHub.ts; Tests: src/services/mcp/tests/hierarchical-mcp.spec.ts. Local MCP tests pass; CI running now. |
| expect(betaCfg.args).toEqual(["pkg.js"]) | ||
| expect(betaConn.server.status).toBe("disconnected") | ||
| }) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding tests with malformed JSON configurations to verify that parsing errors are handled (and ideally logged) without crashing the resolution.
This comment was generated because it violated a code review rule: irule_PTI8rjtnhwrWq6jS.
|
|
||
| // Return from least specific to most specific | ||
| return paths.reverse() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method discovers mcp.json files in parent directories outside the workspace, but there's no corresponding file watcher to monitor changes to these parent directory files. The existing watchProjectMcpFile() method only watches .roo/mcp.json in the workspace directory. Changes to parent directory mcp.json files won't trigger updates, requiring users to restart VSCode to pick up configuration changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review complete. Found 2 issues related to file watching for hierarchical configuration files.
| .map((mode) => ({ ...mode, source: "global" as const })), | ||
| ] | ||
| // Merge with .roomodes taking precedence and preserving expected order | ||
| const mergedModes = await this.mergeCustomModes(allRoomodesModes, settingsModes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new mergeCustomModes call may not correctly override less specific modes. Since getHierarchicalRoomodes returns files from parent to workspace (i.e. more general first), iterating in order means the first (parent) mode wins even if a more specific config exists. Consider iterating the project modes in reverse (or always overriding) so that more specific (.roomodes) entries properly override less specific ones.
| const mergedModes = await this.mergeCustomModes(allRoomodesModes, settingsModes) | |
| const mergedModes = await this.mergeCustomModes(allRoomodesModes.reverse(), settingsModes) |
…s CI in hierarchical .roo resolution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review complete. There are 2 outstanding issues from the previous review that still need to be addressed.
Description
This PR implements hierarchical configuration resolution for .roo directories and .roomodes files in mono-repositories, addressing Issue #8825.
Problem
In mono-repository setups, the current .roo resolution only checks global (~/.roo) and workspace-local directories. This makes it challenging to manage configurations for projects with multiple tech stacks and nested workspace structures.
Solution
This implementation introduces hierarchical directory walking, similar to .editorconfig and nuget.config behavior. The configuration system now:
Changes
Core Implementation
getRooDirectoriesForCwd()insrc/services/roo-config/index.tsto support hierarchical resolutionCustomModesManagerto handle multiple .roomodes files in the hierarchygetHierarchicalRoomodes()method for discovering .roomodes files up the directory treeKey Features
enableHierarchicalparameter (defaults to true)Testing
src/services/roo-config/__tests__/hierarchical-resolution.spec.tsExample
For a project structure:
The resolution order is now:
Breaking Changes
None - the feature is enabled by default but maintains full backward compatibility.
Testing Instructions
enableHierarchical: falseto verify legacy behaviorFixes #8825
Important
Adds hierarchical configuration resolution for
.roodirectories and.roomodesfiles in mono-repositories, with backward compatibility..roodirectories and.roomodesfiles in mono-repos.enableHierarchicalflag (defaults to true).getRooDirectoriesForCwd()inindex.tsfor hierarchical directory resolution.CustomModesManagerandMcpHubto handle hierarchical.roomodesandmcp.jsonfiles.getHierarchicalRoomodes()andgetHierarchicalProjectMcpPaths()methods.hierarchical-resolution.spec.tsandhierarchical-mcp.spec.tsfor hierarchical resolution.McpHub.ts.This description was created by
for 069aaa5. You can customize this summary. It will automatically update as commits are pushed.